package com.ruoyi.draw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.draw.domain.ModelType;
import com.ruoyi.draw.service.IModelTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ModelTypeController
 * 
 * @author Locke
 * @date 2025-10-25
 */
@RestController
@RequestMapping("/model/type")
public class ModelTypeController extends BaseController
{
    @Autowired
    private IModelTypeService modelTypeService;

    /**
     * 查询ModelType列表
     */
    @PreAuthorize("@ss.hasPermi('model:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModelType modelType)
    {
        startPage();
        List<ModelType> list = modelTypeService.selectModelTypeList(modelType);
        return getDataTable(list);
    }

    /**
     * 导出ModelType列表
     */
    @PreAuthorize("@ss.hasPermi('model:type:export')")
    @Log(title = "ModelType", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModelType modelType)
    {
        List<ModelType> list = modelTypeService.selectModelTypeList(modelType);
        ExcelUtil<ModelType> util = new ExcelUtil<ModelType>(ModelType.class);
        util.exportExcel(response, list, "ModelType数据");
    }

    /**
     * 获取ModelType详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(modelTypeService.selectModelTypeById(id));
    }

    /**
     * 新增ModelType
     */
    @PreAuthorize("@ss.hasPermi('model:type:add')")
    @Log(title = "ModelType", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModelType modelType)
    {
        return toAjax(modelTypeService.insertModelType(modelType));
    }

    /**
     * 修改ModelType
     */
    @PreAuthorize("@ss.hasPermi('model:type:edit')")
    @Log(title = "ModelType", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModelType modelType)
    {
        return toAjax(modelTypeService.updateModelType(modelType));
    }

    /**
     * 删除ModelType
     */
    @PreAuthorize("@ss.hasPermi('model:type:remove')")
    @Log(title = "ModelType", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(modelTypeService.deleteModelTypeByIds(ids));
    }
}
